package org.jdamico.socks.server.commons;

import java.net.InetAddress;
import java.util.UUID;

public class UserManager {

	private static UserManager instance = null;
	
	private final String USER_NAME = "admin";
	private final String PASSWORD = "nimda";
	
	private UserManager() {
		
	}
	
	public static  UserManager getInstance() {
		
		if(instance==null) {
			synchronized (UserManager.class) {
				if(instance==null) {
					instance = new UserManager();
				}
				
			}
		}
		return instance;
	}

	public boolean handleUserInfo(String userName, String password) {
		return USER_NAME.equals(userName) && PASSWORD.equals(password);
	}

	public synchronized String  createToken(InetAddress mClientAddress, int mClientPort, String userInfo) {
		StringBuilder sb = new StringBuilder();
		sb.append(mClientAddress.getHostName()).append("_").append(mClientPort).append("_").append(userInfo).append(System.currentTimeMillis());
		return sb.toString();
	}


	
}
